function field() {//头部输入框
    let inpus = document.querySelector("#hard2>.inpu")
    let hearts = document.querySelector("#hard2")
    setInterval(function () {
        let y = window.scrollY;//获取滚动的距离
        if (y >= 500) {
            inpus.classList.add("inpus")
            hearts.classList.add("hearts")
        } else {
            inpus.classList.remove("inpus")
            hearts.classList.remove("hearts")
        }
    }, 100)
}

field()
function peach() {//北京时间轮播图
    let showLI = document.querySelectorAll("#body1 .left_box>.big_box li")
    let yellowLI = document.querySelectorAll("#body1 .left_box>.small_box li")
    for (let i = 0; i < yellowLI.length; i++) {
        yellowLI[i].addEventListener("mouseover", function () {
            for (let a = 0; a < yellowLI.length; a++) {
                yellowLI[a].classList.remove("yellOw")
                showLI[a].classList.remove("show")
            }
            yellowLI[i].classList.add("yellOw")
            showLI[i].classList.add("show")
            index = i;
        })
        // alert(1)
        let index = 0;
        setInterval(function () {
            index++;
            if (index > yellowLI.length - 1) {
                index = 0;
            }
            for (let b = 0; b < yellowLI.length; b++) {
                yellowLI[b].classList.remove("yellOw")
                showLI[b].classList.remove("show")
            }
            yellowLI[index].classList.add("yellOw")
            showLI[index].classList.add("show")
        }, 1500)
    }
}
peach()

function beijing_time() {//ba北京时间显示
    let hourI = document.querySelector("#body1 .left_box>.small_box>i")
    let minutesB = document.querySelector("#body1 .left_box>.small_box>b")
    let secondA = document.querySelector("#body1 .left_box>.small_box>a")
    setInterval(function () {
        let time = new Date();
        let hour = time.getHours()
        let minutes = time.getMinutes()
        let second = time.getSeconds()
        hourI.innerHTML = hour
        minutesB.innerHTML = minutes
        secondA.innerHTML = second

    }, 1000)
}
beijing_time()

function locker() {
    let dd_reveal = document.querySelectorAll("#body1>.carsoual>.right_box>dl dd")
    let dt_conceral = document.querySelectorAll("#body1>.carsoual>.right_box>dl dt")
    let dl = document.querySelector("#body1>.carsoual>.right_box>dl")
    //用循环为dt添加事件
    for (let i = 0; i < dt_conceral.length; i++) {
        dt_conceral[i].addEventListener("mouseenter", function () {
            //di调用播放函数
            play(i);
            index = i;//g改变定时器的索引
        })

    }
    //定义一个播放函数
    function play(i) {
        for (let j = 0; j < dt_conceral.length; j++) {
            dt_conceral[j].classList.remove("conceral")
            dd_reveal[j].classList.remove("reveal")
        }
        dt_conceral[i].classList.add("conceral")
        dd_reveal[i].classList.add("reveal")
    }
    let index = 0;
    let timeID = "";
    autoPlay();//页面打开就会执行
    function autoPlay() {
        timeID = window.setInterval(function () {
            index++;
            if (index > dt_conceral.length - 1) {
                index = 0;
            }
            //调用播放函数
            play(index)
        }, 1000)
    }
    //大盒子的鼠标移入事件
    //停止定时器
    dl.addEventListener("mouseenter", function () {
        window.clearInterval(timeID)
    })
    //大盒子的鼠标移除事件
    //继续执行定时器
    dl.addEventListener("mouseleave", function () {
        autoPlay()
    })

}
locker()

function new_arrival() {//新品上架
    let lis = document.querySelectorAll("#body5>.big_box>.left_box>li")
    for (let i = 0; i < lis.length; i++) {
        lis[i].addEventListener("mouseover", function () {
            for (let a = 0; a < lis.length; a++) {
                lis[a].classList.remove("lis")
            }
            lis[i].classList.add("lis")
            index = i;
        })

    }
    let index = 0;
    setInterval(function () {
        index++;
        if (index > lis.length - 1) {
            index = 0;
        }
        for (let b = 0; b < lis.length; b++) {
            lis[b].classList.remove("lis")
        }
        lis[index].classList.add("lis")
    }, 1000)
}
new_arrival()

function new_drawer() {//新品上架ch抽屉
    let dl = document.querySelector("#body5>.big_box>.right_box>dl")
    let dt = document.querySelectorAll("#body5>.big_box>.right_box>dl dt")
    let dd = document.querySelectorAll("#body5>.big_box>.right_box>dl dd")
    //用循环为dt添加事件
    for (let i = 0; i < dt.length; i++) {
        dt[i].addEventListener("mouseenter", function () {
            //di调用播放函数
            play(i);
            index = i;//g改变定时器的索引
        })

    }
    //定义一个播放函数
    function play(i) {
        for (let j = 0; j < dt.length; j++) {
            dt[j].classList.remove("conceral")
            dd[j].classList.remove("reveal")
        }
        dt[i].classList.add("conceral")
        dd[i].classList.add("reveal")
    }
    let index = 0;
    let timeID = "";
    autoPlay();//页面打开就会执行
    function autoPlay() {
        timeID = window.setInterval(function () {
            index++;
            if (index > dt.length - 1) {
                index = 0;
            }
            //调用播放函数
            play(index)
        }, 1000)
    }
    //大盒子的鼠标移入事件
    //停止定时器
    dl.addEventListener("mouseenter", function () {
        window.clearInterval(timeID)
    })
    //大盒子的鼠标移除事件
    //继续执行定时器
    dl.addEventListener("mouseleave", function () {
        autoPlay()
    })
}
new_drawer()

function furnish() {//du独家提供 选项卡
    let yellowli = document.querySelectorAll("#body6>.heart>.provison>.similarity")
    let show = document.querySelectorAll("#body6>.heart>.frame>.big-box")
    for (let i = 1; i < yellowli.length; i++) {
        yellowli[i].addEventListener("mouseover", function () {
            for (let a = 1; a < yellowli.length; a++) {
                yellowli[a].classList.remove("yellow")
                show[a - 1].classList.remove("show")
            }
            yellowli[i].classList.add("yellow")
            show[i - 1].classList.add("show")
        })
    }
}
furnish()

function first() {//du独家提供 di轮播
    let work_shift = document.querySelectorAll("#body6>.heart>.frame>.first_box>.first_ul>.cursole")
    let dots = document.querySelectorAll("#body6>.heart>.frame>.first_box>.doT .dot")
    for (let i = 0; i < work_shift.length; i++) {
        dots[i].addEventListener("mouseover", function () {
            for (let a = 0; a < work_shift.length; a++) {
                work_shift[a].classList.remove("work_shift")
                dots[a].classList.remove("dots")
            }
            work_shift[i].classList.add("work_shift")
            dots[i].classList.add("dots")
            index = i;
        })

    }
    let index = 0;
    setInterval(function () {
        index++;
        if (index > dots.length - 1) {
            index = 0;
        }
        for (let b = 0; b < work_shift.length; b++) {
            work_shift[b].classList.remove("work_shift")
            dots[b].classList.remove("dots")
        }
        work_shift[index].classList.add("work_shift")
        dots[index].classList.add("dots")
    }, 1000)
}
first()

function beach() {//换一批
    let right = document.querySelector("#body7>.heart>.right")
    let lis = document.querySelectorAll("#body8>.heart>ul li")

    let a = 0;
    right.addEventListener("click", function () {
        a++;
        if (a > lis.length - 1) {
            a = 0;
        }
        for (let o = 0; o < lis.length; o++) {
            lis[o].classList.remove("lis")
        }
        lis[a].classList.add("lis")
    })
}
beach()

